package com.example.domain;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

/**
 * @author zhy
 * @date 2020/08/13 0013 15:02
 * @ @Document(indexName = "itemDomain1", type = "_doc", shards = 5, replicas = 1)说明：
 * @Document：文档对象，indexName:索引库名称，type：在索引库的类型(Elasticsearch7.x取消了type概念)
 * shards：分片数量，默认为5，replicas：副本数量，默认为1
 */
@Data
@Document(indexName = "itemdomain", type = "_doc", shards = 5, replicas = 1)
public class TestDomain1 {

    /*
    @Id：标记一个字段为id主键
     */
    @Id
    private Long id;
    /*
    @Field：标记为文档的字段，type：字段类型，index：是否索引，默认是true，store：是否存储，默认是false
    analyzer：分词器名称
     */
    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String title;// 标题
    @Field(type = FieldType.Keyword)
    private String category;// 分类
    @Field(type = FieldType.Keyword)
    private String brand;// 品牌
    @Field(type = FieldType.Double)
    private Double price;// 价格
    @Field(type = FieldType.Keyword, index = false)
    private String images;// 图片地址

    public TestDomain1() {}

    public TestDomain1(Long id, String title, String category, String brand, Double price, String images) {
        this.id = id;
        this.title = title;
        this.category = category;
        this.brand = brand;
        this.price = price;
        this.images = images;
    }

    @Override
    public String toString() {
        return "TestDomain1{" +
                "id=" + id +
                ", title='" + title + '\'' +
                ", category='" + category + '\'' +
                ", brand='" + brand + '\'' +
                ", price=" + price +
                ", images='" + images + '\'' +
                '}';
    }
}
